-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Nix build files #497
base: main
Are you sure you want to change the base?
Conversation
xeus | ||
xeus-zmq | ||
cppzmq | ||
cling.unwrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default cling
package is meant for use by end-users directly, so it only provides the /bin/cling
script which feeds arguments to the unwrapped version. See my comment on cxxFlags
below for why it needs to be wrapped.
cxxFlags = if useLLVMLibcxx then [ | ||
"-I" "${lib.getDev llvmPackages_9.libcxx}/include/c++/v1" | ||
"-L" "${llvmPackages_9.libcxx}/lib" | ||
"-l" "${llvmPackages_9.libcxx}/lib/libc++.so" | ||
] else [ | ||
"-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}" | ||
"-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/x86_64-unknown-linux-gnu" | ||
]; | ||
|
||
flags = [ | ||
"-nostdinc" | ||
"-nostdinc++" | ||
"-isystem" "${cling.unwrapped}/lib/clang/9.0.1/include" | ||
] ++ cxxFlags ++ [ | ||
"-isystem" "${lib.getDev stdenv.cc.libc}/include" | ||
"-isystem" "${cling.unwrapped}/include" | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The funny thing about Nix is that it's optimized for prebuilt packages, meaning it stores dev outputs (headers, etc...) in a different path than default outputs (executables). This breaks the assumption that they exist at the same prefix, so we force xcpp
to run with those flags set to our development paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nix flakes are basically Nix packages which specify their inputs. The flake.lock
file locks those inputs to a specific commit, allowing for reproducible builds.
I'm not a nix expert, but I do want a bleeding-edge cling in my jupyter without having to mess with conda dev environments. This flake is built against nixpkgs' cling, which is still stuck on 0.9. Given there exist some patches to make xeus-cling compatible with upstream cling, how can I make a flake that builds against a git version of cling? |
Merge this PR atop your patches and override |
This PR proposal adds build files for the Nix package manager, effectively turning this project into a "Nix Flake". The rationale is that C/C++ projects usually induce a lot of interference with the local build environment, which the Nix package manager alleviates.
These files let Nix build
xeus-cling
with all required dependencies, allowing one to install the kernel with a single command:nix profile install github:jupyter-xeus/xeus-cling
, and copying/linking the kernel definition files in~/.nix-profile/share/jupyter/kernels
into~/.local/share/jupyter/kernels
.(another approach for installing kernel defs would be a tiny script like
xcpp-install
that writes kernel defs in the user's Jupyter data directory.)As long as
flake.lock
is committed, all dependencies are pinned to a strict version from the upstream NixOS project. Not committing it will let dependencies update automatically, but this may make builds less reliable.This also provides another way to create a dev environment for working on
xeus-cling
: runningnix develop
, which opens a shell with the build environment Nix itself would use to build a release ofxeus-cling
.This change does not interfere with the rest of the project.